﻿using System.Collections.Generic;
using System.Linq;
using Foothill.Model;

namespace Foothill.Service.AdService
{
    public class AdListFilter : IAdListFilter
    {
        // filter the complete list using linq to objects
        public IList<ForSaleAd> FilterSearchResultList(ForSaleAdAdvancedSearchParameter searchParam, IList<ForSaleAd> completeResultList)
        {
            if (completeResultList == null || completeResultList.Count == 0)
            {
                return completeResultList;
            }
            
            return completeResultList.FilterMakeAndModel(searchParam).FilterCities(searchParam)
                .FilterListingType(searchParam).FilterTransmissionType(searchParam)
                .FilterVehicleCondition(searchParam).FilterMileage(searchParam).FilterYearAge(searchParam).ToList();
        }
    }
}
